﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Linq.Expressions;

namespace ModelProject
{
        public interface IRepository<TEntity> where TEntity : class
        {
            IUnitOfWork UnitOfWork { get; }

            void Add(TEntity item);

            void Add(IList<TEntity> items);

            void Remove(TEntity item);

            void Remove(IList<TEntity> items);

            void Modify(TEntity item);

            IEnumerable<TEntity> GetAll();

            /// <summary>
            /// Get a collection of paged entities.
            /// </summary>
            /// <typeparam name="S"></typeparam>
            /// <param name="pageIndex">Number of page.</param>
            /// <param name="pageCount">Page element size.</param>
            /// <param name="orderByExpression">Order by expression.</param>
            /// <param name="ascending">Is sort ascending?</param>
            /// <returns></returns>
            IEnumerable<TEntity> GetPagedElements<S>(int pageIndex, int pageCount, Expression<Func<TEntity, S>> orderByExpression, bool ascending);

            IEnumerable<TEntity> GetElementsFilteredByExpression(Expression<Func<TEntity, bool>> filter);

            IEnumerable<TEntity> GetElementsFilteredByExpression<S>(Expression<Func<TEntity, bool>> filter, Expression<Func<TEntity, S>> orderByExpression, bool ascending);

            IEnumerable<TEntity> GetElementsFilteredByExpression<S>(Expression<Func<TEntity, bool>> filter, int pageIndex, int pageCount, Expression<Func<TEntity, S>> orderByExpression, bool ascending);

            /// <summary>
            /// Undo changes on entities.
            /// </summary>
            void UndoChanges();
        }
 }
